package com.ccb.jyzx.expand.tiantouonline.view.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.List;

/**
 * @author XIEFEI
 * @date 2019-04-19 16:03
 * @Description 分页查询结果
 **/
@ApiModel(description= "分页查询结果")
public class PageResult<T> implements Serializable {
    public PageResult(int pageNo, int pageSize, int totalCount) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
    }

    public PageResult(int pageNo, int pageSize) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
    }

    public PageResult(int pageNo, int pageSize, int totalCount, List<T> data) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.data = data;
    }

    public PageResult() {
    }

    /**
     * 当前页号
     */
    @ApiModelProperty(value = "当前页号")
    private int pageNo;
    /**
     * 每页记录数
     */
    @ApiModelProperty(value = "每页记录数")
    private int pageSize;
    /**
     * 总页数
     */
    @ApiModelProperty(value = "总页数")
    private int totalPage;

    /**
     * 总记录数
     */
    @ApiModelProperty(value = "总记录数")
    private int totalCount;
    /**
     * 起始记录号
     */
    private int startIndex;

    /**
     * 分页数据
     */
    private List<T> data;

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalPage() {

        return (getTotalCount() + getPageSize() - 1) / getPageSize();
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getNextIndex() {

        return getPageNo() + 1;
    }


    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getStartIndex() {
        return (getPageNo() - 1) * pageSize;
    }

    public void setStartIndex(int startIndex) {
        this.startIndex = startIndex;
    }




}
